//
// Created by 123 on 2025/1/9.
//
#include "map"
#include "iostream"
using namespace std;

void printMap(map<int,int>& m){
    for(map<int,int>::iterator it=m.begin();it!=m.end();it++){
        cout << "key==" << it->first << " value=" << it->second << endl;
    }
    cout << endl;
}

void test(){
    map<int,int> m;
    m.insert(pair<int,int>(3,30));
    m.insert(pair<int,int>(1,10));
    m.insert(pair<int,int>(2,20));
    printMap(m);

    map<int,int>m2(m);
    printMap(m2);

    map<int,int>m3;
    m3 = m2;
    printMap(m3);
}

void test2(){
    map<int,int> m1;
    m1.insert(pair<int,int>(1,100));
    m1.insert(pair<int,int>(3,300));
    m1.insert(pair<int,int>(2,200));
    if (m1.empty()){
        cout << "m1 is empty" << endl;
    }else{
        cout << "m1 is not empty" << endl;
        cout << "m1 size is " << m1.size() << endl;
    }
    printMap(m1);
    map<int,int>m2;
    m2.swap(m1);
    printMap(m2);
}

void test3(){
    map<int,int>m1;
    m1.insert(pair<int,int>(1,10));
    m1.insert(make_pair(2,20));
    m1.insert(map<int,int>::value_type(3,30));
    m1[4] = 40;
    printMap(m1);

    m1.erase(m1.begin());
    printMap(m1);

    m1.erase(3);
    printMap(m1);

    //查找



    m1.erase(m1.begin(),m1.end());
    m1.clear();
    printMap(m1);


}

int main141(){
//    test();
//    test2();
    test3();
    return 0;
}